<%@ page pageEncoding="utf-8" isELIgnored="false" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>校园超市管理系统</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/jsp/css/public.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/jsp/css/style.css"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/js/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/easyui/themes/icon.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/jsp/js/bootstrap/css/bootstrap.min.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jsp/js/jQuery1.11.1.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui/jquery.easyui.min.js"></script>
    <%--  <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.pagination.js"></script>--%>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/js/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
        var  loginOut;
        var insertbill;
        $(function () {
            insertbill = function myinsertbill() {
                $.ajax({
                    url: "${pageContext.request.contextPath}/insertbill",
                    type: "post",
                    data: $("#myform").serialize(),
                    statusCode: {
                        403: function() {
                            $.messager.alert("温馨提示","无权访问","error");
                        }
                    },
                    success: function (data) {
                        if (data.data == 1) {
                            $.messager.alert("温馨提示", "添加成功", "info");
                            setTimeout(function(){
                                location.href="${pageContext.request.contextPath}/jsp/billList.jsp";
                            },2000);
                        } else {
                            $.messager.alert("温馨提示", "添加失败", "error");
                            return false;
                        }
                    }
                });
            }

            $.ajax({
                url: "${pageContext.request.contextPath}/proList",
                type: "post",
                datatype: "json",
                success: function (data) {
                    $.each(data.data, function (i, dom) {

                        $("#supplier").append("<option value=" + dom.id + ">" + dom.proName + "</option>");
                    })
                }
            });
            $("#billNum").blur(function () {
                var com = $("#billCom").val();
                //alert(com);
                if (com == '') {
                    $.messager.alert("温馨提示", "单价不能为空", "question");
                } else {
                    var num = $("#billNum").val();
                    //alert(num);
                    var money = com * num;
                    $("#money").val(money);
                }
            });
            loginOut=function userLoginOut() {
                $.messager.confirm("温馨提示", "确定要退出吗？", function (r) {
                    if (r) {
                        location.href="${pageContext.request.contextPath}/loginout";
                    } else {
                        return false;
                    }

                });
            }
        });
    </script>
</head>
<body>
<!--头部-->
<header class="publicHeader">
    <h1>校园超市管理系统</h1>

    <div class="publicHeaderR">
        <p><span>您好！</span><span style="color: #fff21b">${keyword} ${login}</span> , 欢迎你！</p>
        <%--<a href="login.html">退出</a>--%>
    </div>
</header>
<!--时间-->
<section class="publicTime">
    <span id="time">2015年1月1日 11:11  星期一</span>
    <a href="#">温馨提示：为了能正常浏览，请使用高版本浏览器！（IE10+）</a>
</section>
<!--主体内容-->
<section class="publicMian ">
    <div class="left">
        <h2 class="leftH2">
            <span class="span_gn">功能列表</span>
        </h2>
        <nav>
            <ul class="list">
                <li><a href="${pageContext.request.contextPath}/jsp/productList.jsp">商品管理</a></li>
                <li id="active"><a href="${pageContext.request.contextPath}/jsp/billList.jsp">订单管理</a></li>
                <li><a href="${pageContext.request.contextPath}/jsp/providerList.jsp">供应商管理</a></li>
                <li><a href="${pageContext.request.contextPath}/jsp/userList.jsp">用户管理</a></li>
                <li><a href="${pageContext.request.contextPath}/jsp/password.jsp">密码修改</a></li>
                <%--<li><a href="${pageContext.request.contextPath}/jsp/login.html">退出系统</a></li>--%>
                <li><a onclick="loginOut()">退出系统</a></li>
            </ul>
        </nav>
    </div>
    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>订单管理页面 >> 订单添加页面</span>
        </div>
        <div class="providerAdd">
            <form action="" method="post" id="myform">
                <!--div的class 为error是验证错误，ok是验证成功-->
                <div class="">
                    <label for="billId">订单编码：</label>
                    <input type="text" name="billCode" id="billId" required/>
                    <span>*请输入订单编码</span>
                </div>
                <div>
                    <label for="billName">商品名称：</label>
                    <input type="text" name="productName" id="billName" required/>
                    <span>*请输入商品名称</span>
                </div>
                <div>
                    <label for="billCom">商品单价：</label>
                    <input type="text" name="productUnit" id="billCom" required/>
                    <span>*请输入商品单价</span>

                </div>
                <div>
                    <label for="billNum">商品数量：</label>
                    <input type="text" name="productCount" id="billNum" required/>
                    <span>*请输入大于0的正自然数，小数点后保留2位</span>
                </div>
                <div>
                    <label for="money">总金额：</label>
                    <input type="text" readonly="readonly" name="totalPrice" id="money" required/>
                    <span>*请输入大于0的正自然数，小数点后保留2位</span>
                </div>
                <div>
                    <label>供应商：</label>
                    <select name="providerId" id="supplier">
                        <option value="0">--请选择相应的提供商--</option>

                    </select>
                    <span>*请选择供应商</span>
                </div>
                <div>
                    <label>是否付款：</label>
                    <input type="radio" name="isPayment" value="1"/>未付款
                    <input type="radio" name="isPayment" value="2"/>已付款
                </div>
                <div class="providerAddBtn">
                    <!--<a href="#">保存</a>-->
                    <!--<a href="billList.html">返回</a>-->
                    <input type="button" onclick="insertbill()" value="保存"/>
                    <input type="button" value="返回" onclick="history.back(-1)"/>
                </div>
            </form>
        </div>

    </div>
</section>
<footer class="footer">
    版权归本超市所有
</footer>
<script src="${pageContext.request.contextPath}/jsp/js/time.js"></script>

</body>
</html>